package cn.org.itool.ws.framework.netty.codec;

import cn.org.itool.ws.framework.protocol.service.ProtocolService;
import cn.org.itool.ws.framework.ws.WsServer;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import lombok.extern.log4j.Log4j2;

import java.util.List;

@Log4j2
public class WsTextDecoder extends MessageToMessageDecoder<TextWebSocketFrame> {

    private final static ProtocolService PROTOCOL_SERVICE = WsServer.PROTOCOL_SERVICE;

    @Override
    protected void decode(ChannelHandlerContext ctx, TextWebSocketFrame textWebSocketFrame, List<Object> list){
        // 解析数据
        PROTOCOL_SERVICE.decode(textWebSocketFrame.text(), null, list);
    }
}
